package com.sudo.rpc.server.config;

import com.sudo.rpc.api.service.RmiSetServerService;
import com.sudo.rpc.server.client.ClientRmiRegistryServiceImpl;
import com.sudo.rpc.server.listener.ContextRefreshedListener;
import com.sudo.rpc.server.service.ServerInfoService;
import com.sudo.rpc.server.service.impl.ServerInfoServiceImpl;
import com.sudo.rpc.server.task.ServerInfoModule;
import com.sudo.rpc.server.task.ShellModule;
import com.sudo.rpc.server.task.TestModule;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.rmi.RemoteException;

@Configuration
@EnableConfigurationProperties(FxwRpcProperties.class)
public class FxwRpcAutoConfig {

    @Bean
    public ContextRefreshedListener contextRefreshedListener(){
        return new ContextRefreshedListener();
    }

    @Bean
    public RmiSetServerService rmiSetServerService() throws RemoteException {
        return new ClientRmiRegistryServiceImpl();
    }

    @Bean
    public ServerInfoService serverInfoService() {
        return new ServerInfoServiceImpl();
    }

    @Bean
    public ServerInfoModule serverInfoModule(){
        return new ServerInfoModule();
    }
    @Bean
    public ShellModule shellModule(){
        return new ShellModule();
    }
    @Bean
    public TestModule testModule() {
        return new TestModule();
    }

}
